﻿using System;
using System.Windows.Forms;

using AIthin.Controls;


namespace AIthin.Model
{
    public partial class NeuroNetworkForm : Form
    {
        public NeuroControl NC;
        public NeuroNetworkForm()
        {
            InitializeComponent();
        }

        private void NeuroNetworkForm_FormClosing(object sender, FormClosingEventArgs e)
        {
          if( MessageBox.Show("Save network?","Attention!",MessageBoxButtons.YesNo) == DialogResult.Yes)
                           this.NC.SaveNetworkFile(AIthin.Model.Properties.Settings.Default.WorkingPath);
        }

         public void LoadNetworkFile(String Path, String FileName)
        {
            switch (FileName.Substring(FileName.LastIndexOf('.')))
            {
                case ".nw":
                    
                    break;

                case ".nw1":
                    NeuroControl nc_true = new NeuroControl(Path, FileName);
                    this.NC = /*(INeuroControl)*/nc_true;
                    this.Controls.AddRange(new System.Windows.Forms.Control[] {nc_true});
                    this.structViewControl2.LoadNetwork( ref nc_true );
                    this.NC.WorkingPath = AIthin.Model.Properties.Settings.Default.WorkingPath;

                    NetworkView NWV = new NetworkView();
                    NWV.MdiParent = this.MdiParent;
                    NWV.structViewControl1.LoadNetwork(ref nc_true);
                    NWV.Show();
                    break;

                default:
                    break;
            }


           
        }

         private void structViewControl1_Load(object sender, EventArgs e)
         {

         }
    }
}
